package com.xqzgj.system.service.impl;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xqzgj.system.mapper.StockRecordMapper;
import com.xqzgj.system.domain.StockRecord;
import com.xqzgj.system.service.IStockRecordService;

/**
 * 库存记录Service业务层处理
 * 
 * @author xqzgj
 * @date 2024-03-25
 */
@Service
public class StockRecordServiceImpl implements IStockRecordService {
    @Autowired
    private StockRecordMapper stockRecordMapper;

    /**
     * 查询库存记录列表
     * 
     * @param stockRecord 库存记录
     * @return 库存记录
     */
    @Override
    public List<StockRecord> selectStockRecordList(StockRecord stockRecord) {
        return stockRecordMapper.selectStockRecordList(stockRecord);
    }

    /**
     * 查询库存记录
     * 
     * @param id 库存记录主键
     * @return 库存记录
     */
    @Override
    public StockRecord selectStockRecordById(Long id) {
        return stockRecordMapper.selectStockRecordById(id);
    }

    /**
     * 新增库存记录
     * 
     * @param stockRecord 库存记录
     * @return 结果
     */
    @Override
    public int insertStockRecord(StockRecord stockRecord) {
        return stockRecordMapper.insertStockRecord(stockRecord);
    }

    /**
     * 修改库存记录
     * 
     * @param stockRecord 库存记录
     * @return 结果
     */
    @Override
    public int updateStockRecord(StockRecord stockRecord) {
        return stockRecordMapper.updateStockRecord(stockRecord);
    }

    /**
     * 批量删除库存记录
     * 
     * @param ids 需要删除的库存记录主键
     * @return 结果
     */
    @Override
    public int deleteStockRecordByIds(Long[] ids) {
        return stockRecordMapper.deleteStockRecordByIds(ids);
    }

    /**
     * 删除库存记录信息
     * 
     * @param id 库存记录主键
     * @return 结果
     */
    @Override
    public int deleteStockRecordById(Long id) {
        return stockRecordMapper.deleteStockRecordById(id);
    }

    /**
     * 审批库存记录
     * 
     * @param stockRecord 库存记录
     * @return 结果
     */
    @Override
    public int approveStockRecord(StockRecord stockRecord) {
        return stockRecordMapper.approveStockRecord(stockRecord);
    }

    /**
     * 取消审批库存记录
     * 
     * @param stockRecord 库存记录
     * @return 结果
     */
    @Override
    public int cancelStockRecord(StockRecord stockRecord) {
        return stockRecordMapper.cancelStockRecord(stockRecord);
    }
    
    /**
     * 查询本月入库量
     */
    @Override
    public Long selectMonthlyInStock() {
        return stockRecordMapper.selectMonthlyInStock();
    }

    /**
     * 查询本月出库量
     */
    @Override
    public Long selectMonthlyOutStock() {
        return stockRecordMapper.selectMonthlyOutStock();
    }

    /**
     * 查询日期范围
     */
    @Override
    public List<String> selectDateRange(String startDate, String endDate) {
        return stockRecordMapper.selectDateRange(startDate, endDate);
    }

    /**
     * 查询入库趋势数据
     */
    @Override
    public List<Map<String, Object>> selectInStockTrend(String startDate, String endDate) {
        return stockRecordMapper.selectInStockTrend(startDate, endDate);
    }

    /**
     * 查询出库趋势数据
     */
    @Override
    public List<Map<String, Object>> selectOutStockTrend(String startDate, String endDate) {
        return stockRecordMapper.selectOutStockTrend(startDate, endDate);
    }

    /**
     * 查询入库出库对比数据
     */
    @Override
    public Map<String, Object> selectInOutComparison(String startDate, String endDate) {
        return stockRecordMapper.selectInOutComparison(startDate, endDate);
    }

    /**
     * 查询变动类型分布
     */
    @Override
    public List<Map<String, Object>> selectTypeDistribution(String startDate, String endDate) {
        return stockRecordMapper.selectTypeDistribution(startDate, endDate);
    }

    /**
     * 查询变动类型趋势
     */
    @Override
    public List<Map<String, Object>> selectTypeTrend(String startDate, String endDate) {
        return stockRecordMapper.selectTypeTrend(startDate, endDate);
    }
}